<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>list</title>
[#include "/admin/include/head.htm"]
<script type="text/javascript">
    var grid;
    $(function () {
        grid = $("#maingrid").ligerGrid({
            columns: [
			{hide: true, name: 'id'},
			{display: '标题', name: 'title', align: 'left', minWidth: 120},
			{display: '消息类型', name: 'type', i18n:'SiteNoticeType', align: 'left', width: 100},
			{display: '创建时间', name: 'createDate', align: 'left', width: 300},
			{display: '操作', name: 'id', align: 'left', width: 150, 
				render:function(row){
					return "<a href='javascript:void(0)' style='color:blue' onclick='toMemberList("+row["id"]+",\""+row["title"]+"\")'>查看关联列表</a>";
			
			}}
			],  pageSize:20, url: base + '/admin/b2c/siteNotice/queryTextData.jhtml',
			toolbar: {}, width: '100%', height:'100%', enabledSort: true
        });
        $("#pageloading").hide();
		LG.loadToolbar(grid);
		
		//绑定搜索按钮
		LG.search(grid);
    });
	
	function add(){
		top.f_addTab(null, '新增站内消息', base + '/admin/b2c/siteNotice/add.jhtml?parentMenuNo=site_notice_list');
	}
	
	function edit(){
		var selecteds = grid.getSelecteds();
	    if (selecteds.length == 1) {
			var id = selecteds[0].id;
	    	if(top.f_isTabItemExist("siteNotice" + id)){
				top.f_switchTab("siteNotice" + id);
			}else{
				top.f_addTab("siteNotice" + id, '修改站内消息[' + selecteds[0].title+ ']', '${base}/admin/b2c/siteNotice/edit.jhtml?id=' + id);
			}
	    }else{
	    	LG.tip('请选择一行!');
	    }
	}
	
	function toMemberList(id, title){
		top.f_addTab(null, title, base + '/admin/b2c/siteNotice/list.jhtml?textId='+id+'&parentMenuNo=site_notice_list');
	}
	
	function f_delete() {
		var selecteds = grid.getSelecteds();
	    if (selecteds.length > 0) {
	    	jQuery.ligerDialog.confirm('确定删除吗？', function (confirm) {
      			if (confirm){
					LG.ajax({
						url: base + '/admin/b2c/siteNotice/delText.jhtml',
			            loading: '正在删除中...',
			            data: { ids: LG.getIds(selecteds).join(',') },
			            success: function () {
							LG.showSuccess('删除成功');
			                f_reload();
			            },
			            error: function (message) {
							LG.showError(message);
			            }
			        });
			    }
			});
		} else {
			LG.tip('请选择行!');
	    }
	}
	
	//关联接收者
	function correlateMember(){
		var selecteds = grid.getSelecteds();
		if(selecteds.length == 1){
			if(selecteds[0].type == '所有人'){
				LG.showError("消息类型为所有人，无需关联");
				return;
			}
			$.ligerDialog.open({
				title:"【关联会员】-标题:"+selecteds[0].title, height: 650,width:1250,
				url: base + '${base}/admin/b2c/siteNotice/correlate/'+selecteds[0].id+'.jhtml',isResize: true,
				buttons: [
					{ text: '取消', onclick: function (item, dialog) { dialog.hide();}}
				]
			});
		}else{
			LG.tip('请选择一行!');
		}
	}
</script>
</head>
<body style="padding:10px; overflow:hidden;">
	<div id="functions">
		<div class="clearfix">
			<div style="float:left;">
				<span>
					标题：<input type="text" class="formText" name="search_LIKE_title"/>
				</span>
				<span>
					消息类型：[@u.select_map listKey='key' listValue='name' headerKey="" headerValue="全部"
							headerButtom="false" list=siteNoticeTypeList
							name="search_EQ_type" /]
				</span>
				<input type="button" id="search" class="button" value="搜索"/>
				<a href="#" id="search_btn_reset" face="Wingdings 3">解除搜索,显示全部数据</a>
			</div>
		</div>
	</div>
	<div id="maingrid" style="margin:0; padding:0"></div>
</body>
</html>